import Vue from 'vue'

import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    //公共的变量，这里的变量不能随便修改，只能通过触发mutations的方法才能改变
    openid: 0,
    nickName: '',
    avatarUrl: ''
  },
  mutations: {
    setopenid(state, openid) {
      state.openid = openid
    },
    setNickName(state, nickName) {
      state.nickName = nickName
    },
    setAvatarUrl(state, avatarUrl) {
      state.avatarUrl = avatarUrl
    },
  },
  actions: {
    //相当于异步的操作,不能直接改变state的值，只能通过触发mutations的方法才能改变
  }
})
export default store
